<?php

class Comment extends Eloquent
{

	/**
	 * 
	 * @var unknown
	 */
	protected $fillable = ['commenter', 'email', 'comment'];

	/**
	 * 
	 */
    public function post()
    {
        return $this->belongsTo('Post');
    }

    /**
     * 
     * @param unknown $approved
     * @return string
     */
    public function getApprovedAttribute($approved)
    {
        return (intval($approved) == 1) ? 'yes' : 'no';
    }

    /**
     * 
     * @param unknown $approved
     */
    public function setApprovedAttribute($approved)
    {
        $this->attributes['approved'] = ($approved === 'yes') ? 1 : 0;
    }

}
